using System;
using System.Collections.Generic;
using System.Text;

namespace PerlinNoise.NoiseGenerator
{
    public class PrimeNoiseGenerator : AbstractNoiseGenerator
    {
        public override double noise1D(int x)
        {
            x = (x << 13) ^ x;
            return 1.0d - ((x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0d;
        }

        public override double noise2D(int x, int y)
        {
            int n = x + y * 57;
            n = (n << 13) ^ n;
            return 1.0d - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0d;
        }

        public override double noise3D(int x, int y, int z)
        {
            int n = x + y * 57 + z * 14;
            n = (n << 13) ^ n;
            return 1.0d - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0d;
        }

        public override double noise4D(int x, int y, int z, int t)
        {
            int n = x + y * 57 + z * 13 - t * 23;
            n = (n << 13) ^ n;
            return 1.0d - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0d;
        }
    }
}
